package com.dkm.ec.activity.repository.impl;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.db.persistence.dao.IQueryDao;
import com.dkm.biz.repository.AbstractRepository;
import com.dkm.ec.activity.domain.CommonActivityConfig;
import com.dkm.ec.activity.persistence.dao.CommonActivityConfigQueryDao;
import com.dkm.ec.activity.persistence.entity.CommonActivityConfigPo;
import com.dkm.ec.activity.repository.CommonActivityConfigRepository;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by fanjinyuan on 2017/8/14.
 */
@Repository
public class CommonActivityConfigRepositoryImpl extends AbstractRepository<String, CommonActivityConfigPo, CommonActivityConfig> implements CommonActivityConfigRepository {

    @Resource
    private CommonActivityConfigQueryDao activityConfigQueryDao;

    @Override
    public CommonActivityConfig newInstance() {
        CommonActivityConfigPo po = new CommonActivityConfigPo();
        CommonActivityConfig domain = SpringHelper.getBean(CommonActivityConfig.class);
        domain.setData(po);
        return domain;
    }

    @Override
    public CommonActivityConfig newInstance(CommonActivityConfigPo po) {
        CommonActivityConfig domain = SpringHelper.getBean(CommonActivityConfig.class);
        domain.setData(po);
        return domain;
    }

    @Override
    public List<CommonActivityConfigPo> findTodayActivities(String type) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("type", type);
        return activityConfigQueryDao.findByKey("findTodayActivities", params);
    }

    @Override
    public CommonActivityConfigPo get(String id) {
        return activityConfigQueryDao.get(id);
    }

    @Override
    protected IQueryDao<String, CommonActivityConfigPo> getQueryDao() {
        return activityConfigQueryDao;
    }
}
